// http://www.tuicool.com/articles/iai2YbI
const babel = require('rollup-plugin-babel')
const eslint = require('rollup-plugin-eslint')
const resolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const replace  = require('rollup-plugin-replace')
const uglify  = require('rollup-plugin-uglify')
const image = require('rollup-plugin-image')
const progress = require('rollup-plugin-progress')
const postcss  = require('rollup-plugin-postcss')
const html = require('rollup-plugin-html')

const { name, version } = require('../package.json')

module.exports = {
  entry: 'src/main.js',
  proDest: 'dist/main.js',
  devDest: 'test/main.js',
  format: 'iife',
  sourceMap: 'inline',
  plugins:[
    resolve({
      jsnext: true,
      main: true,
      browser: true,
    }),
    progress({
      clearLine: false
    }),
    commonjs(),
    postcss(),
    image(),
    html({
      include: 'src/*.html'
    }),
    babel({
      exclude: 'node_modules/**',
    }),
    eslint({
      exclude: ['**/*.html', '**/*.css']
    }),
    replace({
      ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
      APPNAME: JSON.stringify(name),
      VERSION: JSON.stringify(`${version}`)
    }),
    (process.env.NODE_ENV === 'production' && uglify())
  ]
}
